import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;

public class IODemo3 {
    public static void main(String[] args) throws IOException {
        try(InputStream inputStream =new FileInputStream("./test.txt")){
            while(true){
                //每次读取一个字节

//                int b=inputStream.read();
//                if(b==-1){
//                    //文件读取结束
//                    break;
//                }
//                System.out.printf("%d ",b);

                byte[] buffer=new byte[1024];
                int n=inputStream.read(buffer);
                if(n==-1){
                    //文件读取结束
                    break;
                }
//                for(int i=0;i<n;i++){
//                    System.out.printf("%d ",buffer[i]);
//                }
                String s=new String(buffer,0,n);
                System.out.println(s);
            }

        }

    }
}
